home *** CD-ROM | disk | FTP | other *** search
/ Tech Arsenal 1 / Tech Arsenal (Arsenal Computer).ISO / tek-01 / wics.zip / EFRAME.CPP < prev    next >
C/C++ Source or Header  |  1993-03-03  |  8KB  |  306 lines

  1. //==============================================================================================
  2. //
  3. //    Windows Interface Construction Set
  4. //    Version 1.00
  5. //
  6. //    EFRAME.CPP - Extended Frame Class
  7. //    Copyright ⌐ 1993 by Microdyne Development Technologies.
  8. //    All rights reserved.
  9. //==============================================================================================
  10.  
  11. #include "eframe.h"
  12.  
  13. //----------------------------------------------------------------------------------------------
  14. //    Constructor for TExtendedMDIFrame
  15. //
  16. //    The TExtendedMDIFrame is the main frame window of the application. This window
  17. //    contains all user work areas as child windows. The routine creates an icon bar
  18. //    control.
  19. //----------------------------------------------------------------------------------------------
  20.  
  21. TExtendedMDIFrame::TExtendedMDIFrame(LPSTR ATitle, LPSTR MenuName, BOOL fIconbar, BOOL fStatusbar, PTModule AModule)
  22.           : TMDIFrame(ATitle, MenuName, AModule)
  23. {
  24.     AnIconBar = ( fIconbar ) ? new TIconBar (this) : NULL ;
  25.     AStatusBar = ( fStatusbar ) ? new TStatusBar (this) : NULL ;
  26.     APrinter = new TPrinter();
  27.  
  28.     idHelpMessage     = RegisterWindowMessage (HELPMSGSTRING);
  29.     idFindTextMessage = RegisterWindowMessage (FINDMSGSTRING);
  30.  
  31.     hBackgroundBrush = CreateSolidBrush (GetSysColor(COLOR_APPWORKSPACE));
  32. }
  33.  
  34. TExtendedMDIFrame::TExtendedMDIFrame(LPSTR ATitle, int MenuId, BOOL fIconbar, BOOL fStatusbar, PTModule AModule)
  35.           : TMDIFrame(ATitle, MenuId, AModule)
  36. {
  37.     AnIconBar = ( fIconbar ) ? new TIconBar (this) : NULL ;
  38.     AStatusBar = ( fStatusbar ) ? new TStatusBar (this) : NULL ;
  39.     APrinter = new TPrinter();
  40.  
  41.     idHelpMessage     = RegisterWindowMessage (HELPMSGSTRING);
  42.     idFindTextMessage = RegisterWindowMessage (FINDMSGSTRING);
  43.  
  44.     hBackgroundBrush = CreateSolidBrush (GetSysColor(COLOR_APPWORKSPACE));
  45. }
  46.  
  47.  
  48. //----------------------------------------------------------------------------------------------
  49. //    Destructor for TExtendedMDIFrame
  50. //
  51. //    The destructor is called when the application terminates. The routine disposes of the
  52. //    icon bar.
  53. //----------------------------------------------------------------------------------------------
  54.  
  55. TExtendedMDIFrame::~TExtendedMDIFrame()
  56. {
  57.     DeleteObject (hBackgroundBrush);
  58.     delete APrinter;
  59. }
  60.  
  61. //----------------------------------------------------------------------------------------------
  62. //    WMSize
  63. //
  64. //    The window processes this message whenever the window changes size. This routine calls the
  65. //    default process (TMDIFrame::WMSize) and then resizes the Iconbar (AnIconBar) and Client area
  66. //    according to the new window size.
  67. //----------------------------------------------------------------------------------------------
  68.  
  69. void TExtendedMDIFrame::WMSize(RTMessage Msg)
  70. {
  71.     TMDIFrame::WMSize(Msg);
  72.  
  73.     if ( AnIconBar )
  74.     {
  75.         if ( AStatusBar )
  76.         {
  77.             SetWindowPos (AnIconBar->HWindow, NULL, -1, -1, LOWORD(Msg.LParam)+2, AnIconBar->GetHeight(), SWP_NOZORDER);
  78.             SetWindowPos (ClientWnd->HWindow, NULL, 0, AnIconBar->GetHeight()-1, LOWORD(Msg.LParam), HIWORD(Msg.LParam)-AnIconBar->GetHeight()-AStatusBar->GetHeight()+2, SWP_NOZORDER);
  79.             SetWindowPos (AStatusBar->HWindow, NULL, -1, HIWORD(Msg.LParam)-AStatusBar->GetHeight()+1, LOWORD(Msg.LParam)+2, AStatusBar->GetHeight(), SWP_NOZORDER);
  80.         }
  81.         else
  82.         {
  83.             SetWindowPos (AnIconBar->HWindow, NULL, -1, -1, LOWORD(Msg.LParam)+2, AnIconBar->GetHeight(), SWP_NOZORDER);
  84.             SetWindowPos (ClientWnd->HWindow, NULL, 0, AnIconBar->GetHeight()-1, LOWORD(Msg.LParam), HIWORD(Msg.LParam)-AnIconBar->GetHeight()+1, SWP_NOZORDER);
  85.         }
  86.     }
  87.     else
  88.     {
  89.         if ( AStatusBar )
  90.         {
  91.             SetWindowPos (ClientWnd->HWindow, NULL, 0, 0, LOWORD(Msg.LParam), HIWORD(Msg.LParam)-AStatusBar->GetHeight()+1, SWP_NOZORDER);
  92.             SetWindowPos (AStatusBar->HWindow, NULL, -1, HIWORD(Msg.LParam)-AStatusBar->GetHeight()+1, LOWORD(Msg.LParam)+2, AStatusBar->GetHeight(), SWP_NOZORDER);
  93.         }
  94.     }
  95. }
  96.  
  97. void TExtendedMDIFrame::GetWindowClass(WNDCLASS _FAR & AWndClass)
  98. {
  99.     TMDIFrame::GetWindowClass(AWndClass);
  100.  
  101.     AWndClass.hbrBackground = hBackgroundBrush;
  102. }
  103.  
  104. void TExtendedMDIFrame::CMPrinterSetup (RTMessage)
  105. {
  106.     APrinter->Configure(this);
  107. }
  108.  
  109. void TExtendedMDIFrame::DefWndProc (RTMessage Msg)
  110. {
  111.     if ( Msg.Message == idHelpMessage )
  112.         WMCommDlgHelp (Msg);
  113.     else
  114.         TMDIFrame::DefWndProc(Msg);
  115. }
  116.  
  117. void TExtendedMDIFrame::WMCommDlgHelp (RTMessage msg)
  118. {
  119.     switch ( msg.WParam )
  120.     {
  121.         case WCDID_OPENFILENAME:
  122.             OpenFileHelp();
  123.             break;
  124.  
  125.         case WCDID_SAVEFILENAME:
  126.             SaveFileHelp();
  127.             break;
  128.  
  129.         case WCDID_CHOOSECOLOR:
  130.             ChooseColorHelp();
  131.             break;
  132.  
  133.         case WCDID_CHOOSEFONT:
  134.             ChooseFontHelp();
  135.             break;
  136.  
  137.         case WCDID_FINDTEXT:
  138.             FindTextHelp();
  139.             break;
  140.  
  141.         case WCDID_REPLACETEXT:
  142.             ReplaceTextHelp();
  143.             break;
  144.  
  145.         case WCDID_PRINTDLG:
  146.             PrintHelp();
  147.             break;
  148.  
  149.         case WCDID_PRINTSETUP:
  150.             PrintSetupHelp();
  151.             break;
  152.     }
  153. }
  154.  
  155. void TExtendedMDIFrame::CheckMenu(UINT id)
  156. {
  157.     HWND    hMenu;
  158.  
  159.     if ((hMenu = GetMenu(HWindow)) != NULL )
  160.         CheckMenuItem (hMenu, id, MF_BYCOMMAND | MF_CHECKED);
  161. }
  162.  
  163. void TExtendedMDIFrame::UncheckMenu (UINT id)
  164. {
  165.     HWND    hMenu;
  166.  
  167.     if ((hMenu = GetMenu(HWindow)) != NULL )
  168.         CheckMenuItem (hMenu, id, MF_BYCOMMAND | MF_UNCHECKED); 
  169. }
  170.  
  171. void TExtendedMDIFrame::FlipMenuCheck (UINT id)
  172. {
  173.     HWND    hMenu;
  174.  
  175.     if ((hMenu = GetMenu(HWindow)) != NULL )
  176.         if ( GetMenuState (hMenu, id, MF_BYCOMMAND) & MF_CHECKED ) 
  177.             CheckMenuItem (hMenu, id, MF_BYCOMMAND | MF_UNCHECKED);
  178.         else
  179.             CheckMenuItem (hMenu, id, MF_BYCOMMAND | MF_CHECKED);             
  180. }
  181.  
  182. void TExtendedMDIFrame::DisableMenuEntry (UINT id)
  183. {
  184.     HWND    hMenu;
  185.  
  186.     if ((hMenu = GetMenu(HWindow)) != NULL )
  187.         EnableMenuItem (hMenu, id, MF_BYCOMMAND | MF_DISABLED | MF_GRAYED); 
  188. }
  189.  
  190. void TExtendedMDIFrame::EnableMenuEntry (UINT id)
  191. {
  192.     HWND    hMenu;
  193.  
  194.     if ((hMenu = GetMenu(HWindow)) != NULL )
  195.         EnableMenuItem (hMenu, id, MF_BYCOMMAND | MF_ENABLED);
  196. }
  197.  
  198. void TExtendedMDIFrame::PlaceIconBarButton (WORD x, WORD y, WORD Id, BOOL fState)
  199. {
  200.     if (AnIconBar )
  201.         AnIconBar->PlaceButton(x,y,Id,fState);
  202. }
  203.  
  204. void TExtendedMDIFrame::PlaceIconBarButton (WORD Id, BOOL fState)
  205. {
  206.     if ( AnIconBar )
  207.         AnIconBar->PlaceButton(Id,fState);
  208. }
  209.  
  210. void TExtendedMDIFrame::PlaceFontSelectionControl (WORD x, WORD y, WORD Id)
  211. {
  212.     if ( AnIconBar )
  213.         AnIconBar->PlaceFontSelectionControl(x,y,Id);
  214. }
  215.  
  216. void TExtendedMDIFrame::PlaceFontSelectionControl (WORD Id)
  217. {
  218.     if ( AnIconBar )
  219.         AnIconBar->PlaceFontSelectionControl(Id);
  220. }
  221.  
  222. void TExtendedMDIFrame::InsertIconBarSpace()
  223. {
  224.     if ( AnIconBar )
  225.         AnIconBar->InsertSpace();
  226. }
  227.  
  228. BOOL TExtendedMDIFrame::IsIconBarButtonChecked (WORD Id)
  229. {
  230.     if ( AnIconBar )
  231.         return AnIconBar->IsButtonChecked(Id);
  232.  
  233.     return FALSE;
  234. }
  235.  
  236. void TExtendedMDIFrame::GetSelectedFontFamilyName (WORD cchMax, LPSTR lpFamilyName)
  237. {
  238.     if ( AnIconBar )
  239.         AnIconBar->GetSelectedFontFamilyName(cchMax, lpFamilyName);
  240.     else
  241.         lstrcpy ( lpFamilyName, "" );
  242. }
  243.  
  244. int    TExtendedMDIFrame::GetSelectedFontSize ()
  245. {
  246.     if ( AnIconBar )
  247.         return AnIconBar->GetSelectedFontSize ();
  248.  
  249.     return 0;
  250. }
  251.  
  252. void TExtendedMDIFrame::RemoveIconBarControl (WORD Id)
  253. {
  254.     if ( AnIconBar )
  255.         AnIconBar->RemoveControl (Id);
  256. }
  257.  
  258. void TExtendedMDIFrame::SetIconBarButtonCommandCode (WORD Id, WORD cmd)
  259. {
  260.     if ( AnIconBar )
  261.         AnIconBar->SetButtonCommandCode (Id, cmd);
  262. }
  263.  
  264. void TExtendedMDIFrame::SetIconBarButtonState (WORD Id, BOOL fState)
  265. {
  266.     if ( AnIconBar )
  267.         AnIconBar->SetButtonState (Id, fState);
  268. }
  269.  
  270. void TExtendedMDIFrame::SetFontFamilyName (LPSTR lpFamilyName)
  271. {
  272.     if ( AnIconBar )
  273.         AnIconBar->SetFontFamilyName (lpFamilyName);
  274. }
  275.  
  276. void TExtendedMDIFrame::SetFontFamilyCommandCode (WORD code)
  277. {
  278.     if ( AnIconBar )
  279.         AnIconBar->SetFontFamilyCommandCode (code);
  280. }
  281.  
  282. void TExtendedMDIFrame::SetFontSize (int s)
  283. {
  284.     if ( AnIconBar )
  285.         AnIconBar->SetFontSize (s);
  286. }
  287.  
  288. void TExtendedMDIFrame::SetFontSizeCommandCode (WORD code)
  289. {
  290.     if ( AnIconBar )
  291.         AnIconBar->SetFontSizeCommandCode (code);
  292. }
  293.  
  294. void TExtendedMDIFrame::SetFontStyle(LOGFONT FAR *lplf)
  295. {
  296.     if ( AnIconBar )
  297.         AnIconBar->SetFontStyle(lplf);
  298. }
  299.  
  300. void TExtendedMDIFrame::SetIconBarStartPoint (WORD x)
  301. {
  302.     if ( AnIconBar )
  303.         AnIconBar->SetStartPoint (x);
  304. }
  305.  
  306.